package kz.vokebuz.demo.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DbOpenHelper extends SQLiteOpenHelper {

	private static final int DATABASE_VERSION = 2;
	private static final String DATABASE_NAME = "smsdb";
	private static final String TABLE_NAME = "smslog";
	private final String COLUMN_ID = "_id";
	private final String COLUMN_TIMESTAMP = "time";
	private final String COLUMN_SENDER = "sender";
	private final String COLUMN_TEXT = "msgtext";
	private final String COLUMN_GROUPID = "groupid";
	private final String TABLE_CREATE = "create table " + TABLE_NAME + " ("
			+ COLUMN_ID + " integer primary key autoincrement ,"
			+ COLUMN_TIMESTAMP + " integer," + COLUMN_SENDER + " text,"
			+ COLUMN_TEXT + " text," + COLUMN_GROUPID + " text);";

	public DbOpenHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(TABLE_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVer, int newVer) {
		// TODO Auto-generated method stub
		db.execSQL("DROP TABLE IF EXISTS todo");
		onCreate(db);
	}


}